package cayte.demo.dict;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

public class ModeListActivity extends Activity {
	private ListView list;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		list = new ListView(this);
		list.setAdapter(new ArrayAdapter<String>(this,
				android.R.layout.simple_expandable_list_item_1, getData()));
		list.setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> list, View view, int pos,
					long id) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(ModeListActivity.this,
						RememberActivity.class);
				intent.putExtra("index", ModeListActivity.this.getIntent()
						.getIntExtra("index", -1));
				intent.putExtra("mode", pos);
				ModeListActivity.this.startActivity(intent);
				ModeListActivity.this.overridePendingTransition(0, 0);
			}
		});

		setContentView(list);
	}

	private List<String> getData() {
		List<String> data = new ArrayList<String>();
		data.add("浏览");
		data.add("英译汉");
		data.add("汉译英");
		return data;
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		// TODO Auto-generated method stub
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			this.finish();
			overridePendingTransition(0, 0);
		}
		return super.onKeyDown(keyCode, event);
	}
}
